let { projectRootPath } = require("../../../util/index");
let { getNewApp } = require(`${projectRootPath}/app/index.js`);
let { verifyToken } = require(`${projectRootPath}/util/jwt/index.js`);
let {
  createUser,
  getUserByPagination,
  editUserByUuid,
  removeUserByUuid,
  getUserByAll,
} = require(`${projectRootPath}/service/user/index.js`);
let app = getNewApp();
// 获取用户信息
app.post("/get", (req, res) => {
  try {
    let token = req.body.token;
    let user = verifyToken(token);
    res.send({ data: user, code: 20000 });
  } catch (error) {
    res.send({ data: {}, message: error.message, code: 20001 });
  }
});
// 获取全部用户
app.post("/get/all", async (req, res) => {
  try {
    let result = await getUserByAll();
    res.send({ data: result, code: 20000 });
  } catch (error) {
    res.send({ data: {}, message: error.message, code: 20001 });
  }
});

// 导出 app
module.exports = app;
